package DataStructureAndAlgorithm.CSP.Day02;

import java.util.*;

//用队列模拟整个窗口的即可
public class AcWing_3198 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        int M = in.nextInt();
        int[] x1 = new int[N + 1];
        int[] y1 = new int[N + 1];
        int[] x2 = new int[N + 1];
        int[] y2 = new int[N + 1];
        Deque<Integer> deque1 = new LinkedList<>();
        Deque<Integer> deque2 = new LinkedList<>();
        for (int i = 1; i <= N; i++) {
            x1[i] = in.nextInt();
            y1[i] = in.nextInt();
            x2[i] = in.nextInt();
            y2[i] = in.nextInt();
            deque1.addLast(N + 1 - i);
        }
        int[] res = new int[M + 1];
        for (int i = 1; i <= M; i++) {
            int x = in.nextInt();
            int y = in.nextInt();
            boolean st = false;
            boolean st1 = false;
            while (!deque1.isEmpty()) {
                int temp = deque1.pollFirst();
                if (x1[temp] <= x && x2[temp] >= x && y1[temp] <= y && y2[temp] >= y) {
                    st = true;
                } else {
                    deque2.addLast(temp);
                }
                if (st == true) {
                    res[i] = temp;
                    System.out.println(temp);
                    while (!deque2.isEmpty()) {
                        deque1.addFirst(deque2.pollLast());
                    }
                    deque1.addFirst(temp);
                    break;
                }
            }
            if (st == false) {
                System.out.println("IGNORED");
            }
            while (!deque2.isEmpty()) {
                deque1.addFirst(deque2.pollLast());
            }
        }

    }
}
